
//身份证获取出生年月和性别

public class Test2 {
    public static void main(String[] args) {
        //获取身份证号码
        String cardId = "510411202409178888";

        //截取年月日和性别
        String year = cardId.substring(6,10);
        String month = cardId.substring(10,12);
        String day = cardId.substring(12,14);

        //判断性别
        int number = cardId.charAt(16) - '0';
        char gender;

        if(number % 2 == 0){
            gender = '女';
        }else {
            gender = '男';
        }

        //输出信息
        System.out.println("人物信息为：");
        System.out.println("出生日期：" + year + "年" + month + "月" + day + "日");
        System.out.println("性别为：" + gender);

    }
}
